import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/common/xindong_all.dart';
import 'package:xindong/utils/xindong_text_util.dart';

class XinDongProfileSectionColumnWidget extends StatelessWidget {
  final Widget child;
  final String title;
  final String? reward;
  final Function()? onTap;

  const XinDongProfileSectionColumnWidget({
    Key? key,
    required this.title,
    this.reward,
    this.onTap,
    required this.child,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    const TextStyle textStyle = TextStyle(color: DZColors.titleColor, fontSize: 16, fontWeight: FontWeight.w600);
    const TextStyle rewardTextStyle = TextStyle(color: DZColors.mainColor, fontSize: 11, height: 1.2);
    return GestureDetector(
      onTap: onTap,
      child: Container(
        color: DZColors.cellColor,
        padding: const EdgeInsets.only(left: 16, right: 10, top: 16, bottom: 16),
        margin: const EdgeInsets.only(top: 8),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Text(title, style: textStyle),
                if (!TextUtil.isEmpty(reward))
                  Container(
                    height: 16,
                    margin: const EdgeInsets.only(left: 8),
                    padding: const EdgeInsets.only(left: 5, right: 5),
                    decoration: BoxDecoration(color: DZColors.mainLightColor, borderRadius: BorderRadius.circular(3)),
                    child: Row(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Text(reward!, style: rewardTextStyle),
                      ],
                    ),
                  ),
                const Expanded(child: SizedBox()),
                if (onTap != null) XinDongAll.instance.defaultIconNext,
              ],
            ),
            child,
          ],
        ),
      ),
    );
  }
}
